#!/bin/bash

DEPLOY_DIR="D:\\deploy/${APP_NAME}"

mkdir -p "$DEPLOY_DIR"
cd "$DEPLOY_DIR"

touch "$DEPLOY_DIR/pid"
pid=`cat $DEPLOY_DIR/pid`
if [ -n "$pid" ]
then
   echo "kill -9 pid:" $pid
   kill -9 $pid
fi

cp "${WORKSPACE}/build/libs/${APP_NAME}.jar"  "$DEPLOY_DIR/${APP_NAME}.jar"

BUILD_ID=dontKillMe nohup java -jar -Dserver.port=9999 "$DEPLOY_DIR/${APP_NAME}.jar"  &

echo "$!" > "$DEPLOY_DIR/pid"